#include "CObject.h"

CObject* CRuntimeClass::CreateObject()
{
    if (nullptr == m_pfnCreateObject) return nullptr;

    return (*m_pfnCreateObject)();
}

BOOL CRuntimeClass::IsDerivedFrom(const CRuntimeClass* pBaseClass) const
{
    const CRuntimeClass* pThis = this;

    while (pThis)
    {
        if (pThis == pBaseClass) return TRUE;
        pThis = pThis->m_pBaseClass;
    }

    return FALSE;
}

const CRuntimeClass CObject::classCObject =
{
    "CObject",
    sizeof(CObject),
    0x01,
    NULL,
    NULL,
    NULL
};

CObject::CObject()
{
}

CObject::~CObject()
{
}

CRuntimeClass* CObject::GetRuntimeClass() const
{
    return (CRuntimeClass*)&CObject::classCObject;
}

BOOL CObject::IsKindOf(const CRuntimeClass* pClass) const
{
    CRuntimeClass* pThis = GetRuntimeClass();

    return pThis->IsDerivedFrom(pClass);
}


